 var aProgressImages;
 var hIntevalID;


 function startScan()
 {
   var sTunerStatus = tuner.GetStatus();

   if( "TunerStatus_Ready" == sTunerStatus ||
       "TunerStatus_Tuned" == sTunerStatus) {

     for(i=0; i < aProgressImages.length; i++) {
       aProgressImages[i].src="images/opt_tv/off.gif";
     }

     tuner.ScanStart();
     hIntevalID = setInterval("updateScanStatus()", 500);
   }
 }

 function scanAbort()
 {
   tuner.scanAbort();
   clearInterval(hIntevalID);
 }

 function updateScanStatus()
 {
   var sScanStatus;
   var sReg;
   var iScanningChannel;
   var iPercent;
   var iChannelsFound;

   sScanStatus = tuner.GetScanStatus();
   //Parse out the scan details
   sReg = sScanStatus.match(/ScanningChannel:(\w+) Complete:(\w+) ChannelsFound:(\w+)/);
   iScanningChannel = sReg[1];
   iPercent  = sReg[2];
   iChannelsFound  = sReg[3];

   iOnImages = 20 * (iPercent/100);

   for(i=0; i < iOnImages; i++) {
     aProgressImages[i].src="images/opt_tv/on.gif";
   }
   
   mainform.iNumberOfChannels.value=iChannelsFound;

   if(100 == iPercent) {
     clearInterval(hIntevalID);
   }


 }

 function doOnLoad()
 {
   //Create an array of images of only the progress images
   aProgressImages = [
     document.i5,
     document.i10,
     document.i15,
     document.i20,
     document.i25,
     document.i30,
     document.i35,
     document.i40,
     document.i45,
     document.i50,
     document.i55,
     document.i60,
     document.i65,
     document.i70,
     document.i75,
     document.i80,
     document.i85,
     document.i90,
     document.i95,
     document.i100      
   ];
  }
    
